//今日涨停股排序
function getAjaxProduct(type,object){
	switch (clickarray.toString()){
		case "2,2,1":
			stockVue.stockList = object.sort(sortObject('upRisePercent','stockCode')).reverse();
			break;
		case "2,2,0":
			stockVue.stockList = object.sort(sortObject('upRisePercent','stockCode'));
			break;
		case "2,1,2":
			stockVue.stockList = object.sort(sortObject('nowPrice','stockCode')).reverse();
			break;
		case "2,0,2":
			stockVue.stockList = object.sort(sortObject('nowPrice','stockCode'));
			break;
		case "1,2,2":
			stockVue.stockList = object.sort(sortObject('limitGene','stockCode')).reverse();
			break;
		case "0,2,2":
			stockVue.stockList = object.sort(sortObject('limitGene','stockCode'));
			break;					
	}
}

function sortObject(str1,str2){
	return function(a,b){
		var const_ab = a[str1] - b[str1];
		if(const_ab != 0){
			return const_ab;
		}
		return  a[str2] - b[str2];
	}
}
//涨停监控tab数据排序
function getAjaxProductLimit(object){

	switch (controlGlobal.orderType){
		case 'rise':
			controlGlobal.sortType == 'desc' ? (limitControlVue.stockControlList = object.sort(sortObject('currentIncrease','stockCode')).reverse()) : (limitControlVue.stockControlList = object.sort(sortObject('currentIncrease','stockCode')));
			break;
		case 'fiveRise':
			controlGlobal.sortType == 'desc' ? (limitControlVue.stockControlList = object.sort(sortObject('fiveMinRise','stockCode')).reverse()) : (limitControlVue.stockControlList = object.sort(sortObject('fiveMinRise','stockCode')));
			break;
		case 'sell':
			controlGlobal.sortType == 'desc' ? (limitControlVue.stockControlList = object.sort(sortObject('sellPower','stockCode')).reverse()) : (limitControlVue.stockControlList = object.sort(sortObject('sellPower','stockCode')));
			break;
		case 'buy':
			controlGlobal.sortType == 'desc' ? (limitControlVue.stockControlList = object.sort(sortObject('buyPower','stockCode')).reverse()) : (limitControlVue.stockControlList = object.sort(sortObject('buyPower','stockCode')));
			break;
		case 'maxRise':
			controlGlobal.sortType == 'desc' ? (limitControlVue.stockControlList = object.sort(sortObject('todayMaxRise','stockCode')).reverse()) : (limitControlVue.stockControlList = object.sort(sortObject('todayMaxrise','stockCode')));
			break;				

	}

	// 处理买手力量和卖手力量数据显示
	$.each(limitControlVue.stockControlList,function(key,value){
		var floatSc = '';
		var acStr = value.sellPower.toString();
		if(acStr.length >=5){
			var cc = parseFloat(acStr)/10000;
			if(acStr.length >=8 && acStr.length <9){
				floatSc = cc.toFixed(1) + '万';
			}else if(acStr.length >=9){
				floatSc = cc.toFixed(3) + '亿';
			}else{
				floatSc = cc.toFixed(2) + '万';
			}
			
			Vue.set(limitControlVue.$data.stockControlList[key],'sellPower',floatSc);
		}
	});

	$.each(limitControlVue.stockControlList,function(key,value){
		var floatSc = '';
		var acStr = value.buyPower.toString();
		if(acStr.length >=5){
			var cc = parseFloat(acStr)/10000;
			if(acStr.length >=8 && acStr.length <9){
				floatSc = cc.toFixed(1) + '万';
			}else if(acStr.length >=9){
				floatSc = cc.toFixed(3) + '亿';
			}else{
				floatSc = cc.toFixed(2) + '万';
			}
			Vue.set(limitControlVue.$data.stockControlList[key],'buyPower',floatSc);
		}
	});


	// vue 视图更新后，重新渲染dom
	Vue.nextTick(function(){

		//设置阴影的高度
		var shadowH = setInterval(function(){
			var h = $('.product_left').height();
			if(h>1){
				clearInterval(shadowH);
				$('.listWrap .shadow_left').css({
					'height': h 
				});
			}
		},20);
		
		setTimeout(function(){
			$.each(limitControlVue.stockControlList,function(key,value){
				if(value.limitRemind == 1){  //关闭push开关
					var index = key + 1;
					$('.product_left_control>ul:nth-child('+index+') .switchLimit').animate({'left':'0.43rem'},'linear',300,function(){
						$('.product_left_control>ul:nth-child('+index+') .switchLimit').parent().find('span').addClass('addRedBack');
					});
				}else{   // 打开push开关
					var index = key + 1;
					$('.product_left_control>ul:nth-child('+index+') .switchLimit').animate({'left':'0.03rem'},'linear',300,function(){
						$('.product_left_control>ul:nth-child('+index+') .switchLimit').parent().find('span').removeClass('addRedBack');
					});
				}
			});
		},300);
	});
}
